import { SET_PRODUCTS, EDIT_PRODUCTS, DEL_PRODUCTS } from './actionsType'
import { getProducts } from '../api'

export function setProducts() {
	// 异步action  需要redux-thunk
	return async dispatch => {
		const resp = await getProducts()
		dispatch({ type: SET_PRODUCTS, payload: resp.data.data })
	}
}

export function editProduct(payload) {
	return { type: EDIT_PRODUCTS, payload }
}

export function delProducts(payload) {
	return { type: DEL_PRODUCTS, payload }
}